package com.jin.crud.controller;

import com.jin.crud.bean.LoginUser;
import com.jin.crud.bean.SysUser;
import com.jin.crud.common.utils.ResultUtil;
import com.jin.crud.common.utils.SecurityUtils;
import com.jin.crud.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author yuxuejin
 * @Date 2021/11/27 13:38
 * @Description: 个人信息 业务处理
 */
@RestController
@RequestMapping("/system/user/profile")
public class SysProfileController {

    @Autowired
    private SysUserService userService;

    @GetMapping("getUserProfile")
    public ResultUtil getUserProfile() {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = userService.getUser(loginUser.getUserId());
        String roleGroup = userService.selectUserRoleGroup(user.getUserName());
        Map<Object, Object> map = new HashMap<>();
        map.put("user", user);
        map.put("roleGroup", roleGroup);
        return ResultUtil.resultSuccess(map);
    }

}
